{% macro gen_table(demands, url) %}
    <table id="demand-info-table"
           class="table table-bordered table-hover table-condensed table-striped">
        <thead>
        <tr>
            <th>用户ID</th>
            <th style="width: 9%;">手机号</th>
            <th>用户昵称</th>
            <th>需求分类</th>
            <th>故障</th>
            <th>类型</th>
            <th>环境</th>
            <th>大小</th>
            <th>颜色</th>
            <th>间距</th>
            <th>省份</th>
            <th>城市</th>
            <th>状态</th>
            <th>客服</th>
            <th>发布次数</th>
            <th>创建时间</th>
            <th>发布时间</th>
            <th>处理人</th>
            <th>处理结果</th>
            <th>成功人数</th>
            <th>重发成功人数</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for demand, renewable_demand in demands %}
            <tr>
                {% if demand.owner %}
                    <td>
                        <a
                                href="{{ url_for('op_bp.user_info', user_id=demand.owner.id) }}"
                                target="_blank"
                        >{{ demand.owner.id }}</a>
                    </td>
                    <td>{{ demand.owner.mobile | encrypt }}</td>
                    <td>{{ demand.owner.nickname }}</td>
                {% else %}
                    <td></td>
                    <td></td>
                    <td></td>
                {% endif %}
                <td>{{ demand.cate_display }}</td>
                <td>{{ demand.malf_display }}</td>
                <td>{{ demand.type_display }}</td>
                <td>{{ demand.surr_display }}</td>
                <td>{{ demand.size }}平方米</td>
                <td>{{ demand.color_display }}</td>
                <td>{{ demand.span }}</td>
                <td>{{ demand.prov }}</td>
                <td>{{ demand.city }}</td>
                <td>{{ demand.status_display }}</td>
                <td>{{ demand.admin_display }}</td>
                <td>{{ demand.published_count }}</td>
                <td>{{ demand.created_datetime }}</td>
                <td>{{ demand.published_datetime }}</td>
                <td>{{ renewable_demand.operator_name }}</td>
                <td>{{ renewable_demand.operated_status_display }}</td>
                <td>{{ renewable_demand.success_count }}</td>
                <td>{{ renewable_demand.recovery_success_count }}</td>
                <td style="white-space: nowrap; overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis;">
                    <a
                            class="btn btn-xs btn-primary btn-group"
                            href="{{ url_for('op_bp.demand_info', demand_id=demand.id) }}"
                            name="demand-info"
                            target="_blank"
                    >编辑</a>
                    {% if renewable_demand.operated_status == 0 %}
                        {% if demand.status not in (200, 410) and not demand.is_locked %}
                            <a
                                    class="btn btn-xs btn-success btn-group"
                                    href="{{ url_for('op_bp.publish_demand', demand_id=demand.id) }}"
                                    name="demand-publish"
                                    target="_blank"
                            >{% if demand.published_count>0 %}二次发布{% else %}
                                首发{% endif %}</a>
                        {% endif %}
                        <a
                                class="btn btn-xs btn-info for-renewable-training-btn"
                                href="{{ url_for('op_bp.training_renewable_demand', record_id=renewable_demand.id) }}?redirect_url={{ url_for(url) }}"
                        >赠送</a>

                        <a
                                class="btn btn-xs btn-danger for-renewable-operate-btn"
                                href="javascript:void(0);"
                                role="button"
                                data-placement="left"
                                data-record_id="{{ renewable_demand.id }}"
                                data-operated_status="30"
                                data-toggle="popover"
                                data-trigger="focus"
                                title="操作失败"
                                data-content=""
                        >作废</a>
                    {% endif %}

                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endmacro %}
